package com.cctc.security.util;

public interface SqlUtil
{
    
    static final String HIBERNATE_UUID = "org.hibernate.id.UUIDGenerator";
    
    /**
     * 根据用户账号获取姓名 SQL
     */
    static final String SQL_USER_GET_NAME_BY_ACCOUNT = "SELECT NAME FROM  CCTCT_USERS WHERE ACCOUNT=?";
    
    /**
     * 获取用户名称的
     */
    static final String NAME_USER_GET_NAME_BY_ACCOUNT = "";
    /**
     * 根据权限名称获取资源 SQL
     */
    static final String SQL_GET_RESOURCES_BY_AUTHORITIE_NAME = "SELECT R.ID AS ID ,R.NAME AS NAME ,R.DESCRIPTION AS DESCRIPTION ,R.ENABLED AS ENABLED,R.IS_SYS AS IS_SYS,R.PRIORITY AS PRIORITY ,R.URL AS URL,R.TYPE AS TYPE FROM CCTCT_RESOURCES_AUTHORITIES RA,CCTCT_RESOURCES R,CCTCT_AUTHORITIES A  WHERE RA.AUTHORITIE_ID=A.ID AND RA.RESOURCE_ID=R.ID AND A.NAME=?";
    
    /**
     * 根据用户账户获取权限 SQL
     */
    static final String SQL_GET_AUTHORITIE_NAME_BY_USER_ACCOUNT = "SELECT  A.NAME AS AUTHORITIES_NAME FROM  CCTCT_AUTHORITIES A,CCTCT_GROUPS R,CCTCT_GROUPS_AUTHORITIES RA,CCTCT_USERS U,CCTCT_USERS_GROUPS  UR WHERE A.ID=RA.AUTHORITIE_ID AND R.ID=RA.GROUP_ID AND R.ID=UR.GROUP_ID AND U.ID=UR.USER_ID AND U.ACCOUNT=?";
    
    static final String NAME_GET_AUTHORITIE_NAME_BY_USER_ACCOUNT = "getAuthoritiesByUserAccount";
    
    static final String RSM_GET_AUTHORITIE_NAME_BY_USER_ACCOUNT = "rsmAuthoritiesByUserAccount";
    
    /**
     * 获取所有权限名称 SQL
     */
    static final String SQL_GET_ALL_AUTHORITIES_NAME = "SELECT NAME AS AUTHORITIES_NAME FROM CCTCT_AUTHORITIES";
    
    /**
     * 根据权限名称获取资源
     */
    static final String NAME_GET_RESOURCES_BY_AUTHORITIE_NAME = "getResourcesByAuthoritieName";
    
    static final String NAME_GET_ALL_AUTHORITIES_NAME = "getAllAuthoritieName";
    
    static final String RSM_GET_ALL_AUTHORITIES_NAME = "rsmAllAuthoritieName";
    
    /**
     * 根据权限名称获取资源的URl
     */
    static final String SQL_GET_RESOURCE_URL_BY_AUTHORITE_NAME = "SELECT URL FROM CCTCT_RESOURCES R JOIN CCTCT_RESOURCES_AUTHORITIES RA ON R.ID =RA.RESOURCE_ID JOIN CCTCT_AUTHORITIES  A ON RA.AUTHORITIE_ID =A.ID WHERE A.NAME=?";
    
    static final String NAME_GET_RESOURCE_URL_BY_AUTHORITE_NAME = "getResourcesUrlByAuthoriteName";
    
    static final String RSM_GET_RESOURCE_URL_BY_AUTHORITE_NAME = "rsmResourcesUrlByAuthoriteName";
    
}
